//
//  HXDHeaderView.m
//  qingDaoCircleOfLife
//
//  Created by huxuedong on 15/11/28.
//  Copyright © 2015年 huxuedong. All rights reserved.
//

#import "HXDHeaderView.h"
#import <UIImageView+WebCache.h>

@interface HXDHeaderView ()

@property (weak, nonatomic) IBOutlet UIImageView *iconImage;
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *scoreLabel;
@property (weak, nonatomic) IBOutlet UIButton *shareButton;
@property (weak, nonatomic) IBOutlet UILabel *addressLabel;
@property (weak, nonatomic) IBOutlet UILabel *phoneLabel;
@property (weak, nonatomic) IBOutlet UILabel *introLabel;
@property (weak, nonatomic) IBOutlet UILabel *serverLabel;
@property (weak, nonatomic) IBOutlet UIImageView *starImage;

@end

@implementation HXDHeaderView

+ (instancetype)headerView {
    return [[NSBundle mainBundle] loadNibNamed:@"HXDHeaderView" owner:nil options:nil].lastObject;
}

- (void)awakeFromNib {
    self.shareButton.layer.cornerRadius = 5;
    self.shareButton.clipsToBounds = YES;
    self.introLabel.numberOfLines = 0;
}

- (void)setShopModel:(HXDShop *)shopModel {
    _shopModel = shopModel;
    [self.iconImage sd_setImageWithURL:[NSURL URLWithString:shopModel.cover]];
    self.titleLabel.text = shopModel.name;
    self.scoreLabel.text = [NSString stringWithFormat:@"%@.0分",shopModel.score];
    self.addressLabel.text = shopModel.address;
    self.phoneLabel.text = shopModel.phone;
    self.introLabel.text = shopModel.intro;
    self.serverLabel.text = shopModel.server;
    self.starImage.image = [UIImage imageNamed:[NSString stringWithFormat:@"star_%@",shopModel.score]];
}

- (IBAction)shareAction {
    [[NSNotificationCenter defaultCenter] postNotificationName:@"share" object:nil];
}

@end
